package com.chapter10.homework_.homework05;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
public class Person {
    private String name;
    private Vehicles vehicles;

    public Person(String name, Vehicles vehicles) {
        this.name = name;
        this.vehicles = vehicles;
    }

    public void passRiver() {
        //先得到船
        if (!(vehicles instanceof Boat)){
            vehicles = factory.getBoat();
        }
        vehicles.work();
    }

    public void common() {
        if (!(vehicles instanceof Horse)) {
            vehicles = factory.getHorse();
        }
        vehicles.work();
    }
    public void passVolcano(){
        if (!(vehicles instanceof Plane)){
            vehicles = factory.getPlane();
        }
        vehicles.work();
    }
}
